﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;

public partial class Controls_Home_News : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;

        NewsWeb _NewsWeb = new NewsWeb();
        List<NewsWeb> list;

        list = _NewsWeb.GetList(24, 0, 4);
        _NewsWeb = list[0];

        if (string.IsNullOrEmpty(_NewsWeb.ImageUrl)) _NewsWeb.ImageUrl = "no_image.jpg";
        ltrTopNews.Text = Resources.Html.HomeTopNews;
        ltrTopNews.Text = ltrTopNews.Text.Replace("$Link$", _NewsWeb.Url);
        ltrTopNews.Text = ltrTopNews.Text.Replace("$Title$", _NewsWeb.Title);
        ltrTopNews.Text = ltrTopNews.Text.Replace("$ImageUrl$", AppUtils.ImageUrl(_NewsWeb.ImageUrl, "386", "254"));
        ltrTopNews.Text = ltrTopNews.Text.Replace("$Time$", _NewsWeb.PublishedTime.ToString("HH'h'mm | dd/MM/yyyy"));
        ltrTopNews.Text = ltrTopNews.Text.Replace("$Lead$", _NewsWeb.SubLead);

        list.RemoveAt(0);
        rptList.DataSource = list;
        rptList.DataBind();
    }
}